package tool

import (
	"strconv"

	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/container"
	"fyne.io/fyne/v2/widget"

	"github.com/phuhao00/sugar"
)

func sugarr() {
	w := fyne.CurrentApp().NewWindow("https://github.com/phuhao00/sugar")
	exepath := widget.NewEntry()
	msg := widget.NewLabel("")
	entry1:=widget.NewEntry()
	entry1.SetText("2")
	entry1.PlaceHolder="min or input1"
	entry2:=widget.NewEntry()
	entry2.SetText("9")
	entry2.PlaceHolder="max or input2"
	entry3:=widget.NewEntry()
	entry3.SetText("5")
	entry3.PlaceHolder="value"
	entry4:=widget.NewEntry()
	entry4.SetText("0")
	entry4.PlaceHolder="result"
	btnDo := widget.NewButton("Clamp1", func() {
		min,_:=strconv.Atoi(entry1.Text)
		max,_:=strconv.Atoi(entry2.Text)
		value,_:=strconv.Atoi(entry3.Text)
		clamp := sugar.Clamp(value, min, max)
		entry4.SetText(strconv.Itoa(clamp))
	})
	ctnClamp:=container.NewGridWithColumns(5,entry1,entry2,entry3,btnDo)
	top := container.NewVBox(exepath, ctnClamp)
	w.SetContent(container.NewBorder(top, msg, nil, nil, entry4))
	w.Resize(fyne.NewSize(800, 700))
	w.Show()
}

